//
// Created by 86138 on 2025/6/20.
//

#ifndef QINGDAO_UNIVERSITY_BSTREE_H
#define QINGDAO_UNIVERSITY_BSTREE_H
#include "../01-intro/c1-1.h"

namespace sweetcookie9_2 {
    typedef int KeyType;

    struct ElemType {
        KeyType key;
        int others;
    };

    typedef struct BSTNode {
        ElemType data;
        struct BSTNode *lchild, *rchild;
    } BSTNode, *BSTree;

    BSTree SearchBST(BSTree T, KeyType key);

    Status SearchBST(BSTree T, KeyType key, BSTree f, BSTree &p);

    Status InsertBST(BSTree &T, ElemType e);

    void InOrderTraverse(BSTree T);

    void PreOrderTraverse(BSTree T);

    void InputFromFile(FILE* f, ElemType &c);

    Status DeleteBST(BSTree &T, KeyType key);

    void DeleteBST(BSTree &p);
}
#endif //QINGDAO_UNIVERSITY_BSTREE_H
